<template>
	<view class="container">
		<!-- 页面标题 -->
		<!-- <view class="header">
			<text class="title">设置</text>
		</view> -->

		<!-- 设置列表 -->
		<view class="settings-list card">
			<!-- 个人信息设置 -->
			<view class="settings-group">
				<view class="group-title">个人信息</view>
				<view class="setting-item" @click="navigateTo('profile')">
					<view class="setting-left">
						<uni-icons type="person" size="20"></uni-icons>
						<text>个人资料</text>
					</view>
					<uni-icons type="arrowright" size="16"></uni-icons>
				</view>
				<view class="setting-item" @click="navigateTo('account')">
					<view class="setting-left">
						<uni-icons type="locked" size="20"></uni-icons>
						<text>账号安全</text>
					</view>
					<uni-icons type="arrowright" size="16"></uni-icons>
				</view>
			</view>

			<!-- 通知设置 -->
			<!-- <view class="settings-group">
				<view class="group-title">通知设置</view>
				<view class="setting-item">
					<view class="setting-left">
						<uni-icons type="notification" size="20"></uni-icons>
						<text>推送通知</text>
					</view>
					<switch :checked="settings.notifications" @change="toggleSetting('notifications')" color="#3498db" />
				</view>
				<view class="setting-item">
					<view class="setting-left">
						<uni-icons type="sound" size="20"></uni-icons>
						<text>声音提醒</text>
					</view>
					<switch :checked="settings.sound" @change="toggleSetting('sound')" color="#3498db" />
				</view>
			</view> -->

			<!-- 隐私设置 -->
			<view class="settings-group">
				<view class="group-title">隐私设置</view>
				<view class="setting-item">
					<view class="setting-left">
						<uni-icons type="eye" size="20"></uni-icons>
						<text>学习记录可见</text>
					</view>
					<switch :checked="settings.studyVisible" @change="toggleSetting('studyVisible')" color="#3498db" />
				</view>
			</view>

			<!-- 其他设置 -->
			<view class="settings-group">
				<view class="group-title">其他</view>
				<view class="setting-item" @click="clearCache">
					<view class="setting-left">
						<uni-icons type="trash" size="20"></uni-icons>
						<text>清除缓存</text>
					</view>
					<text class="cache-size">{{cacheSize}}</text>
				</view>
				<view class="setting-item" @click="navigateTo('about')">
					<view class="setting-left">
						<uni-icons type="info" size="20"></uni-icons>
						<text>关于我们</text>
					</view>
					<uni-icons type="arrowright" size="16"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			settings: {
				notifications: true,
				sound: true,
				studyVisible: true
			},
			cacheSize: '2.5MB'
		}
	},
	methods: {
		navigateTo(page) {
			uni.navigateTo({
				url: `/pages/settings/${page}`
			})
		},
		toggleSetting(key) {
			this.settings[key] = !this.settings[key]
			// 这里可以添加保存设置到后端或本地存储的逻辑
			uni.showToast({
				title: '设置已更新',
				icon: 'success'
			})
		},
		clearCache() {
			uni.showModal({
				title: '提示',
				content: '确定要清除缓存吗？',
				success: (res) => {
					if (res.confirm) {
						// 这里添加清除缓存的逻辑
						this.cacheSize = '0KB'
						uni.showToast({
							title: '缓存已清除',
							icon: 'success'
						})
					}
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	padding: 30rpx;
	background-color: #f5f5f5;
	min-height: 100vh;
}

.header {
	margin-bottom: 30rpx;
	.title {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
	}
}

.settings-list {
	background: #fff;
	border-radius: 12rpx;
	overflow: hidden;
}

.settings-group {
	margin-bottom: 20rpx;
	
	.group-title {
		padding: 20rpx 30rpx;
		font-size: 28rpx;
		color: #666;
		background-color: #f8f9fa;
	}
}

.setting-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx;
	background: #fff;
	border-bottom: 2rpx solid #f0f0f0;

	&:last-child {
		border-bottom: none;
	}

	.setting-left {
		display: flex;
		align-items: center;
		gap: 20rpx;

		text {
			font-size: 28rpx;
			color: #333;
		}
	}

	.cache-size {
		font-size: 26rpx;
		color: #999;
	}
}

.card {
	background: #fff;
	border-radius: 12rpx;
	box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
</style> 